package thread;

class TestYield  implements Runnable{
	private int x;
	public void run(){
		for (int i = 0; i < 5; i++) {
			System.out.println(Thread.currentThread().getName()+" "+i);
			if (i==2) {
				Thread.yield();
			}
			
		}
		}
	
	public static void main(String[] args) throws InterruptedException {
		TestYield st=new TestYield();
		Thread st1=new Thread(st,"newThread1");
		Thread st2=new Thread(st,"newThread2");
		Thread.currentThread().setPriority(2);
	for (int i = 0; i < 50; i++) {
		System.out.println(Thread.currentThread().getName()+" "+i);
		if (i==20) {
			st1.start();
			st1.setPriority(Thread.MAX_PRIORITY);//1-10
			st2.start();
			st2.setPriority(Thread.MIN_PRIORITY);//1-10

		}
		
	}	
	}
}